package yzserver.sx4a;

import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;
import yzserver.sx4a.department.Sx4aDepartment;
import yzserver.sx4a.district.Sx4aDistrict;
import yzserver.sx4a.form.*;
import yzserver.sx4a.job.Sx4aJob;
import yzserver.sx4a.org.Sx4aOrg;
import yzserver.sx4a.permission.Sx4aPermission;
import yzserver.sx4a.position.Sx4aPosition;
import yzserver.sx4a.role.Sx4aRole;
import yzserver.sx4a.user.Sx4aUser;

import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: andrew
 * Date: 14-8-15
 * Time: 下午3:16
 * To change this template use File | Settings | File Templates.
 */
public class TestClent {
    public static void main(String[] args) throws MalformedURLException,
            Exception {


//////////////////////////
        Service serviceModel = new ObjectServiceFactory().create(Sx4aUser.class);
        String serviceURL =  "http://localhost:8002/portal/service/Sx4aUser";
        XFireProxyFactory factory = new XFireProxyFactory();
        Sx4aUser client = (Sx4aUser)factory.create(serviceModel, serviceURL);
        User u = new User();
        u.setUid("test1y");
        User u2 = new User();
        u2.setUid("test2y");
        List list = new ArrayList();
        list.add(u);
        list.add(u2);
        Ret r = client.sendAllUser(list);
//       User serviceResponse = client.selUser("test01012");
//        //List<User> serviceResponses = client.selAllUser("all");
//       serviceResponse.setUserCategory("uc");
//        //Ret t = client.operationUser("001","0");
//       Ret t = client.editUser(serviceResponse);
       //Ret t = client.delUser("11");
//        Ret t = client.editUser(serviceResponse);
       // Ret t = client.operationUserPwd("admin","12345678");

        String serviceURLOrg =  "http://localhost:8002/portal/service/Sx4aOrg";
        Service serviceModelorg = new ObjectServiceFactory().create(Sx4aOrg.class);
        Sx4aOrg clientorg = (Sx4aOrg)factory.create(serviceModelorg, serviceURLOrg);
//        Org o = clientorg.selOrg("123");
//        o.setOrgname("12");
        //Ret t = clientorg.updOrg(o);
//        yzserver.sx4a.org.Organization org = new yzserver.sx4a.org.Organization();
//        org.setId("test1");
//        org.setName("test1z");
//        yzserver.sx4a.org.Organization org2 = new yzserver.sx4a.org.Organization();
//        org2.setId("test12");
//        org2.setName("test12z");
//        List list = new ArrayList();
//        list.add(org);
//        list.add(org2);
//
//        clientorg.sendAllOrganization(list);
//
//        String serviceURLdis=  "http://localhost:8002/portal/service/Sx4aDistrict";
//        Service serviceModeldis = new ObjectServiceFactory().create(Sx4aDistrict.class);
//        Sx4aDistrict clientorg = (Sx4aDistrict)(new XFireProxyFactory()).create(serviceModeldis, serviceURLdis);
//        //List<District> list = clientorg.selAllDistrict("all");
//        District d = clientorg.selDistrict("1011");
        //d.setDisplayname("12");
        //Ret t = clientorg.addDistrict(d);
        //Ret t = clientorg.delDistrict("102202");


//        String serviceURLDep=  "http://localhost:8002/portal/service/Sx4aDepartment";
//        Service serviceModeldep = new ObjectServiceFactory().create(Sx4aDepartment.class);
//        Sx4aDepartment clientorg = (Sx4aDepartment)(new XFireProxyFactory()).create(serviceModeldep, serviceURLDep);
//        //List<Department> list = clientorg.selAllDepartment("all");
//        Department d = clientorg.selDepartment("1022");
//        d.setDepartmentid("12212");
//        d.setDeptLevel("2");
//        Ret t = clientorg.addDepartment(d);
        //Ret t = clientorg.delDepartment("1011");
       // Ret t = clientorg.delDepartment("1021");
//        System.out.println("1");

//        String serviceURLDep=  "http://localhost:8002/portal/service/Sx4aPosition";
//        Service serviceModeldep = new ObjectServiceFactory().create(Sx4aPosition.class);
//        Sx4aPosition clientorg = (Sx4aPosition)(new XFireProxyFactory()).create(serviceModeldep, serviceURLDep);
//        List<Department> list = clientorg.selAllPosition("all");
//        Position d = clientorg.selPosition("1022");
//        d.setPositionid("1011");
       // Ret t = clientorg.addPosition(d);
       // Ret t = clientorg.delPosition("1011");
//        Ret t = clientorg.delDepartment("1021");
        //System.out.println("1");

//        String serviceURLDep=  "http://localhost:8002/portal/service/Sx4aJob";
//        Service serviceModeldep = new ObjectServiceFactory().create(Sx4aJob.class);
//        Sx4aJob clientorg = (Sx4aJob)(new XFireProxyFactory()).create(serviceModeldep, serviceURLDep);
//        List<Department> list = clientorg.selAllJob("all");
//        Job d = clientorg.selJob("1022");
//        d.setJobname("1011");
        //Ret t = clientorg.updJob(d);
        //Ret t = clientorg.addJob(d);
//        Ret t = clientorg.delJob("1011");
        //Ret t = clientorg.delDepartment("1021");


//        String serviceURLDep=  "http://localhost:8002/portal/service/Sx4aRole";
//        Service serviceModeldep = new ObjectServiceFactory().create(Sx4aRole.class);
//        Sx4aRole clientorg = (Sx4aRole)(new XFireProxyFactory()).create(serviceModeldep, serviceURLDep);
//       // List<Department> list = clientorg.selAllRole("all");
//        Role d = clientorg.selRole("1022");
//        d.setRolename("1011");
////        d.setRoleid("1011");
//        //Ret t = clientorg.editRole(d);
//        //Ret t = clientorg.addRole(d);
//       // Ret t = clientorg.delRole("1011");
//        System.out.println("1");

//        String serviceURLDep=  "http://localhost:8002/portal/service/Sx4aPermission";
//        Service serviceModeldep = new ObjectServiceFactory().create(Sx4aPermission.class);
//        Sx4aPermission clientorg = (Sx4aPermission)(new XFireProxyFactory()).create(serviceModeldep, serviceURLDep);
//        List<Permission> list = clientorg.selAllPermission("all");
//        Permission d = clientorg.selPermission("1022");
//        d.setPermissionname("1011");
//        d.setPermissionid("1011");
//        //Ret t = clientorg.updPermission(d);
//        //Ret t = clientorg.addPermission(d);
//        Ret t = clientorg.delPermission("1011");
        System.out.println("1");

    }


}



